/* 
[00:00.000] 作词 : 许嵩
[00:00.150] 作曲 : 许嵩
[00:00.300]
[00:15.150]是否每一部戏都看得完整场
[00:22.050]是否每一天过得都有多难忘
[00:29.000]表情迟钝可能因为比较爱想
[00:35.950]不擅长眉目表达
[00:41.710]总在盼望 总在失望
[00:45.160]日子还不都这样
[00:48.660]俗的无畏 雅的轻狂
[00:52.160]还不都是一副臭皮囊
[00:58.960]他们说快写一首情歌雅俗共赏
*/

const parseExp = /\[(\d{2}):(\d{2})\.(\d{2,3})\]/;

export function parseLyric(lycricString){
  const lineStrings = lycricString.split("\n");
  const lyticArr = []

  for(let line of lineStrings){
    if(line){
      const result = parseExp.exec(line);
      if(!result) continue;
      const time1 = result[1] * 60 * 1000;
      const time2 = result[2] * 1000;
      const time3 = result[3].length === 3 ? result[3] *1 : result[3] * 10;
      const time = time1 + time2 + time3;
      const content = line.replace(parseExp,"").trim();
      const lineObj = {time,content};
      lyticArr.push(lineObj);
    }
  }
  return lyticArr;
}